import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class WanFuMoDang extends BaseSkill {
  private readonly COUNTER_DAMAGE_RATIO = 0.5;

  constructor() {
    super(
      'wanFuMoDang',
      '万夫莫当',
      SkillType.Passive,
      DamageType.Physical,
      0.3,        // 30% 触发概率
      0,          // 无CD
      1           // 1回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (!this.canUse() || Math.random() > this.probability) return;

    // 添加反击效果
    source.addEffect({
      type: 'counter',
      value: source.attributes.power * this.COUNTER_DAMAGE_RATIO,
      duration: this.duration,
      stackable: false,
      source: this.id
    });
  }
}
